<template>
    <view>
        <!-- #ifdef H5 -->
        <uv-sticky customNavHeight="44px">
            <view class="tool">
                <uv-button type="primary" @click="gotoTaskPage(SYSFORMOPERTYPE.Add)"
                    v-if="store.userInfo.UserType == 0">
                    创建任务
                </uv-button>
            </view>
        </uv-sticky>
        <!-- #endif -->
        <!-- #ifndef H5 -->
        <uv-sticky>
            <view class="tool">
                <uv-button type="primary" @click="gotoTaskPage(SYSFORMOPERTYPE.Add)"
                    v-if="store.userInfo.UserType == 0">
                    创建任务
                </uv-button>
            </view>
        </uv-sticky>
        <!-- #endif -->

        <template v-for="item in childrenList" :key="item.Id">
            <view class="cards mx-30 mt-30" @click="goshow(item)">
                <view class="card-title df jsb">
                    <view class="card-title-name">{{ item.text }}</view>
                    <uv-icon name="arrow-right"></uv-icon>
                </view>
            </view>
        </template>
        <uv-gap height="30rpx"></uv-gap>
    </view>
</template>

<script lang="ts" setup>
import { useUserChildrenList } from '@/hooks/useOptions'
import { useUserStore } from '@/stores'
import { SYSFORMOPERTYPE } from '@/utils/enum'

const { childrenList, fetchUserChildrenList } = useUserChildrenList()

onLoad((e) => {
    fetchUserChildrenList(1)
})
const store = useUserStore()

const gotoTaskPage = (optype, id = '') => {
    uni.navigateTo({
        url: '/pages/home/xcxx-task?optype=' + SYSFORMOPERTYPE.Add,
    })
    // switch (optype) {
    //     case SYSFORMOPERTYPE.View:
    //         uni.navigateTo({
    //             url: '/pages/home/xcxx-task1?optype=' + SYSFORMOPERTYPE.View + '&id=' + id
    //         });
    //         break;
    //     case SYSFORMOPERTYPE.Add:
    //         uni.navigateTo({
    //             url: '/pages/home/xcxx-task?optype=' + SYSFORMOPERTYPE.Add
    //         });
    //         break;
    //     case SYSFORMOPERTYPE.Edit:
    //         uni.navigateTo({
    //             url: '/pages/home/xcxx-task?optype=' + SYSFORMOPERTYPE.Edit + '&id=' + id
    //         });
    //         break;
    // }
}

const goshow = (item) => {
    uni.navigateTo({
        url: `/pages/home/xcxx-list-town?TownCode=${item.TownCode}`,
    })
}
</script>

<style lang="scss" scoped>
.tool {
    text-align: center;
    padding: 0rpx 40rpx;
    background-color: #fff;
}

.card-title-name {
    color: #000000;
    font-size: 32rpx;
    font-weight: bold;
    padding-left: 16rpx;
}
</style>
